<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    .red {
      color: red
    }
  </style>
  <script src="../lib/vue-2.4.0.js"></script>
</head>

<body>
  <!-- 需求：默认第一个星级大战是红色.然后点击哪个电影，其变红色 -->
  <div id="app">
    <ul>
      <li v-for="(item, index) in movies" :key="index" :class="{red:index===currentIndex}" @click="changeColor">{{item}}
      </li>
    </ul>
  </div>
  <script>
    const app = new Vue({
      el: "#app",
      data() {
        // console.log(this)
        return {
          movies: ['星级大战', '大话西游', '少年派', '盗梦空间'],
          currentIndex: 0

        }
      },
      methods: {
        changeColor(index) {
          this.currentIndex=index
        }
      },

    })
  </script>

</body>


</html>